import sys,os,shutil,random
isfile = os.path.isfile

from my import *
from .utils import *

toolname = getToolName()

def getArgv():
    _thisArgInd = sys.argv.index(toolname)
    return [i.replace("/","\\") for i in sys.argv[_thisArgInd:]]

def func(isHelp=False):
    if(isHelp):
        return [toolname, "~ %s file1 file2"%(toolname),"#swap file"]
    argv = getToolArgv()
    
    if(len(argv) < 2):return print(func(1))
    if(not isfile(argv[0]) or not isfile(argv[1])):
        return print(func(1), 'not file?')
    
    # breakpoint()
    # os.chdir(str(pathlib.Path(argv[0]).with_name("_"))[:-1])
    # cwd = str(pathlib.Path(os.getcwd()).absolute())
    now = 'C:\\Temp\\swap.tmp'
    
    shutil.copy(argv[0],now)
    print(now)
    shutil.move(argv[1],argv[0])
    print(argv[0])
    shutil.move(now,argv[1])
    print(argv[1])
    